package com.tbb.app.base.vo;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.tbb.app.base.entity.Note;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;

import java.util.Date;

@Data
@Accessors(chain = true)
@AllArgsConstructor
@NoArgsConstructor
@ApiModel(description = "笔记VO")
public class NoteAdminVO {

    @ApiModelProperty("笔记id")
    private String id;

    @ApiModelProperty("标题")
    private String title;

    @ApiModelProperty("作者账号")
    private String userAccount;

    @ApiModelProperty("作者昵称")
    private String userName;

    @ApiModelProperty("状态，0-未发布，1-已发布")
    private Integer status;

    @ApiModelProperty("创建时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date createTime;

    @ApiModelProperty("修改时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date updateTime;

    public NoteAdminVO(Note n) {
        this.id = n.getId();
        this.createTime = n.getCreateTime();
        this.updateTime = n.getUpdateTime();
        this.title = n.getTitle();
        this.status = n.getIsPublish() ? 1 : 0;
    }
}
